package com.caigou.component;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/**
 * @FileName: BaiDuPushComponent
 * @Author: 小飞
 * @Date: 2021/12/13 0013
 * @Description:
 */
@Slf4j
@Component
public class BaiDuPushComponent {

    @Value("${baiDuToken}")
    private String baiDuToken;

    @Resource
    private RestTemplate restTemplate;

    /**
     * www下百度提交方法
     * @param urlList url列表
     */
    public void wwwBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://www.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit www.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit www.caigou2003.com result={}", result);
    }

    /**
     * jundui下百度提交方法
     * @param urlList url列表
     */
    public void junDuiBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://jundui.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit jundui.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit jundui.caigou2003.com result={}", result);
    }

    /**
     * qiche下百度提交方法
     * @param urlList url列表
     */
    public void qiCheBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://qiche.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit qiche.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit qiche.caigou2003.com result={}", result);
    }

    /**
     * it下百度提交方法
     * @param urlList url列表
     */
    public void itBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://it.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit it.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit it.caigou2003.com result={}", result);
    }

    /**
     * dianti下百度提交方法
     * @param urlList url列表
     */
    public void dianTiBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://dianti.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit dianti.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit dianti.caigou2003.com result={}", result);
    }

    /**
     * jiaju下百度提交方法
     * @param urlList url列表
     */
    public void jiaJuBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://jiaju.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit jiaju.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit jiaju.caigou2003.com result={}", result);
    }

    /**
     * kongtiao下百度提交方法
     * @param urlList url列表
     */
    public void kongTiaoBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://kongtiao.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit kongtiao.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit kongtiao.caigou2003.com result={}", result);
    }


    /**
     * hebei下百度提交方法
     * @param urlList url列表
     */
    public void heBeiBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://hebei.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit hebei.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit hebei.caigou2003.com result={}", result);
    }

    /**
     * henan下百度提交方法
     * @param urlList url列表
     */
    public void heNanBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://henan.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit henan.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit henan.caigou2003.com result={}", result);
    }

    /**
     * shandong 下百度提交方法
     * @param urlList url列表
     */
    public void shanDongBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://shandong.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit shandong.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit shandong.caigou2003.com result={}", result);
    }

    /**
     * liaoning 下百度提交方法
     * @param urlList url列表
     */
    public void liaoNingBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://liaoning.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit liaoning.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit liaoning.caigou2003.com result={}", result);
    }

    /**
     * jiangsu 下百度提交方法
     * @param urlList url列表
     */
    public void jiangSuBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://jiangsu.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit jiangsu.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit jiangsu.caigou2003.com result={}", result);
    }

    /**
     * zhejiang 下百度提交方法
     * @param urlList url列表
     */
    public void zheJiangBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://zhejiang.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit zhejiang.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit zhejiang.caigou2003.com result={}", result);
    }

    /**
     * fujian 下百度提交方法
     * @param urlList url列表
     */
    public void fuJianBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://fujian.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit fujian.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit fujian.caigou2003.com result={}", result);
    }

    /**
     * hubei 下百度提交方法
     * @param urlList url列表
     */
    public void huBeiBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://hubei.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit hubei.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit hubei.caigou2003.com result={}", result);
    }

    /**
     * hainan 下百度提交方法
     * @param urlList url列表
     */
    public void haiNanBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://hainan.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit hainan.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit hainan.caigou2003.com result={}", result);
    }

    /**
     * guizhou 下百度提交方法
     * @param urlList url列表
     */
    public void guiZhouBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://guizhou.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit guizhou.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit guizhou.caigou2003.com result={}", result);
    }

    /**
     * yunnan 下百度提交方法
     * @param urlList url列表
     */
    public void yunNanBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://yunnan.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit yunnan.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit yunnan.caigou2003.com result={}", result);
    }

    /**
     * shaanxi 下百度提交方法
     * @param urlList url列表
     */
    public void shaanXiBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://shaanxi.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit shaanxi.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit shaanxi.caigou2003.com result={}", result);
    }

    /**
     * beijing 下百度提交方法
     * @param urlList url列表
     */
    public void beiJingBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://beijing.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit beijing.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit beijing.caigou2003.com result={}", result);
    }

    /**
     * tianjin 下百度提交方法
     * @param urlList url列表
     */
    public void tianJinBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://tianjin.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit tianjin.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit tianjin.caigou2003.com result={}", result);
    }

    /**
     * chongqing 下百度提交方法
     * @param urlList url列表
     */
    public void chongQingBaiDuPush(List<String> urlList){
        String api_url = "http://data.zz.baidu.com/urls?site=https://chongqing.caigou2003.com&token="+baiDuToken;
        StringBuilder urlBuffer = new StringBuilder();
        for (String url : urlList) {
            urlBuffer.append(url).append("\n");
        }
        log.info("submit chongqing.caigou2003.com urls={}", urlBuffer.toString());
        System.out.println(urlBuffer.toString());
        HttpHeaders headers = new HttpHeaders();
        headers.add("Host", "data.zz.baidu.com");
        headers.add("User-Agent", "curl/7.12.1");
        headers.add("Content-Length", "83");
        headers.add("Content-Type", "text/plain");
        HttpEntity<String> entity = new HttpEntity<>(urlBuffer.toString(), headers);
        String result = restTemplate.postForObject(api_url, entity, String.class);
        log.info("submit chongqing.caigou2003.com result={}", result);
    }
}
